package com.ai.fortune_matrix.service.impl;


import com.ai.fortune_matrix.domain.LotteryStatus;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

import java.time.LocalDate;
import java.util.function.Function;


/**
 * @Author: zjg
 * @Date: 2025/5/16 16:19
 * @Description:
 **/
@Configuration
public class AssistantTools {


    public record DetailsRequest(String preNumber, String name) {
    }

    public record CancelRequest(String preNumber, String name) {
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public record LotteryDetails(String preNumber, String name, LocalDate date, LotteryStatus ltStatus) {
    }

    /**
     * 通过 @Bean + Function<...> 注册为可被模型调用的函数
     * 并与具体业务实现类进行解耦
     * @return
     */
    @Bean
    @Description("获取彩票预测号码详细信息")
    public Function<DetailsRequest, LotteryDetails> getLotteryDetails() {
        return request -> {
            try {
                return new LotteryDetails("05、12、16、22、27、30,08", "lottery", LocalDate.now(), LotteryStatus.CONFIRMED);
            }
            catch (Exception e) {
                return new LotteryDetails("05、12、16、22、27、30,08", "lottery", null, null);
            }
        };
    }

    @Bean
    @Description("修改彩票预测号码")
    public Function<CancelRequest, String> changeLottery() {
        return request -> {

            return "修改成功";
        };
    }

    @Bean
    @Description("取消彩票预测号码")
    public Function<CancelRequest, String> cancelLottery() {
        return request -> {
            System.out.println("jaha  正在取消中。。。。");
            return "取消成功";
        };
    }
}
